<template>
  <div class="train-error-container">
    <div class="error-content">
      <div class="train-scene">
        <div class="train">
          <div class="locomotive">
            <div class="head"></div>
            <div class="body">
              <div class="window front-window"></div>
              <div class="window"></div>
              <div class="window"></div>
            </div>
            <div class="pantograph"></div>
            <div class="bottom-line"></div>
          </div>
          <div class="carriage">
            <div class="window"></div>
            <div class="window"></div>
            <div class="window"></div>
            <div class="door"></div>
            <div class="bottom-line"></div>
          </div>
        </div>
        <div class="tracks">
          <div class="sleeper"></div>
          <div class="sleeper"></div>
          <div class="sleeper"></div>
          <div class="sleeper"></div>
          <div class="sleeper"></div>
          <div class="sleeper"></div>
          <div class="sleeper"></div>
          <div class="sleeper"></div>
          <div class="sleeper"></div>
          <div class="broken-track">
            <div class="broken-piece"></div>
            <div class="broken-piece"></div>
          </div>
        </div>
      </div>

      <div class="error-message">
        <div class="error-code">404</div>
        <div class="error-title">页面未找到</div>
        <div class="error-desc">
          很抱歉，您请求的页面不存在。
          <br>请检查您输入的网址是否正确，或者该页面可能已被移除。
        </div>
        <div class="actions">
          <router-link to="/" class="home-button">
            <span class="icon">
              <i class="el-icon-back"></i>
            </span>
            <span>返回首页</span>
          </router-link>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Page404',
  methods: {
    reportIssue() {
      this.$message({
        message: '问题已记录，感谢您的反馈',
        type: 'success',
        duration: 3000
      });
    }
  }
}
</script>

<style lang="scss" scoped>
.train-error-container {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  height: 100vh;
  background: linear-gradient(135deg, #2c3e50 0%, #1a2533 100%);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  font-family: "Helvetica Neue", Arial, sans-serif;
  color: #f0f0f0;
  z-index: 2000;
}

.error-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 90%;
  max-width: 980px;
}

.train-scene {
  width: 100%;
  height: 240px;
  position: relative;
  margin-bottom: 40px;
}

.train {
  position: absolute;
  left: 0;
  bottom: 40px;
  display: flex;
  animation: trainMove 8s infinite linear;
  filter: drop-shadow(0 5px 10px rgba(0,0,0,0.3));
  transform: scaleX(-1);
  
  .locomotive {
    width: 180px;
    height: 60px;
    position: relative;
    
    .head {
      position: absolute;
      width: 70px;
      height: 40px;
      background: linear-gradient(135deg, #ffffff 0%, #f0f0f0 100%);
      border-radius: 50px 5px 0 0;
      left: 0;
      bottom: 20px;
      z-index: 3;
      
      &:before {
        content: "";
        position: absolute;
        left: 10px;
        bottom: 28px;
        width: 15px;
        height: 3px;
        background-color: #cc0000;
        box-shadow: 0 0 5px rgba(255,0,0,0.5);
        border-radius: 3px;
      }
      
      &:after {
        content: "";
        position: absolute;
        left: 35px;
        bottom: 28px;
        width: 15px;
        height: 3px;
        background-color: #cc0000;
        box-shadow: 0 0 5px rgba(255,0,0,0.5);
        border-radius: 3px;
      }
    }
    
    .body {
      position: absolute;
      width: 160px;
      height: 60px;
      background: linear-gradient(to bottom, #ffffff 0%, #f0f0f0 100%);
      border-radius: 0 10px 10px 0;
      right: 0;
      bottom: 0;
      z-index: 2;
      border-top: 2px solid #4080ff;
      border-bottom: 2px solid #4080ff;
      
      &:before {
        content: "";
        width: 160px;
        height: 2px;
        background-color: #4080ff;
        position: absolute;
        top: 20px;
        left: 0;
      }
    }
    
    .window {
      position: absolute;
      height: 18px;
      background-color: rgba(135, 206, 235, 0.8);
      top: 10px;
      border-radius: 4px;
      box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
      
      &.front-window {
        width: 35px;
        left: 70px;
        z-index: 4;
      }
      
      &:nth-of-type(2) {
        width: 25px;
        right: 60px;
      }
      
      &:nth-of-type(3) {
        width: 25px;
        right: 20px;
      }
    }
    
    .pantograph {
      position: absolute;
      top: -15px;
      right: 80px;
      width: 20px;
      height: 15px;
      background-color: #333;
      z-index: 1;
      
      &:before {
        content: "";
        position: absolute;
        top: -2px;
        left: 5px;
        width: 10px;
        height: 2px;
        background-color: #666;
      }
    }
    
    .bottom-line {
      position: absolute;
      bottom: 5px;
      left: 70px;
      width: 110px;
      height: 10px;
      background-color: #333;
      border-radius: 5px;
      z-index: 1;
    }
  }
  
  .carriage {
    width: 150px;
    height: 60px;
    background: linear-gradient(to bottom, #ffffff 0%, #f0f0f0 100%);
    margin-left: -5px;
    border-radius: 5px;
    position: relative;
    z-index: 1;
    border-top: 2px solid #4080ff;
    border-bottom: 2px solid #4080ff;
    
    &:before {
      content: "";
      width: 150px;
      height: 2px;
      background-color: #4080ff;
      position: absolute;
      top: 20px;
      left: 0;
    }
    
    .window {
      position: absolute;
      width: 25px;
      height: 18px;
      background-color: rgba(135, 206, 235, 0.8);
      top: 10px;
      border-radius: 4px;
      box-shadow: inset 0 0 5px rgba(0,0,0,0.2);
      
      &:nth-of-type(1) {
        left: 15px;
      }
      
      &:nth-of-type(2) {
        left: 50px;
      }
      
      &:nth-of-type(3) {
        left: 85px;
      }
    }
    
    .door {
      position: absolute;
      width: 20px;
      height: 40px;
      background-color: #e8e8e8;
      right: 15px;
      bottom: 0;
      border-radius: 2px 2px 0 0;
      
      &:before {
        content: "";
        position: absolute;
        width: 2px;
        height: 30px;
        background-color: #ccc;
        right: 9px;
        top: 5px;
      }
    }
    
    .bottom-line {
      position: absolute;
      bottom: 5px;
      left: 20px;
      width: 110px;
      height: 10px;
      background-color: #333;
      border-radius: 5px;
    }
  }
}

.tracks {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 20px;
  display: flex;
  align-items: flex-end;
  
  &:before, &:after {
    content: "";
    position: absolute;
    height: 8px;
    background-color: #707070;
    width: 100%;
    z-index: 1;
  }
  
  &:before {
    bottom: 0;
  }
  
  &:after {
    bottom: 18px;
  }
  
  .sleeper {
    width: 40px;
    height: 12px;
    background-color: #505050;
    margin-right: 40px;
    z-index: 2;
  }
  
  .broken-track {
    position: absolute;
    right: 40px;
    bottom: 0;
    height: 20px;
    width: 80px;
    z-index: 3;
    animation: blinkBroken 2s infinite;
    
    .broken-piece {
      position: absolute;
      height: 8px;
      width: 60px;
      background-color: #B0332A;
      transform-origin: left;
      
      &:first-child {
        bottom: 0;
        transform: rotate(15deg);
      }
      
      &:last-child {
        bottom: 18px;
        transform: rotate(-20deg);
      }
    }
  }
}

.error-message {
  text-align: center;
  max-width: 600px;
  
  .error-code {
    font-size: 120px;
    font-weight: 700;
    color: #CCCCCC;
    line-height: 1;
    text-shadow: 3px 3px 0 rgba(0, 0, 0, 0.2);
    margin-bottom: 10px;
    opacity: 0;
    animation: fadeIn 0.8s 0.5s forwards;
  }
  
  .error-title {
    font-size: 32px;
    font-weight: 600;
    margin-bottom: 20px;
    color: #D0D0D0;
    opacity: 0;
    animation: fadeIn 0.8s 0.8s forwards;
  }
  
  .error-desc {
    font-size: 18px;
    line-height: 1.6;
    color: #A0A0A0;
    margin-bottom: 30px;
    opacity: 0;
    animation: fadeIn 0.8s 1.1s forwards;
  }
  
  .actions {
    display: flex;
    justify-content: center;
    gap: 20px;
    opacity: 0;
    animation: fadeIn 0.8s 1.4s forwards;
    
    .home-button, .report-button {
      display: flex;
      align-items: center;
      gap: 8px;
      padding: 12px 20px;
      border-radius: 30px;
      font-size: 16px;
      font-weight: 500;
      cursor: pointer;
      transition: all 0.3s ease;
      border: none;
      outline: none;
      
      .icon {
        display: flex;
        align-items: center;
        justify-content: center;
      }
    }
    
    .home-button {
      background-color: #3498db;
      color: white;
      box-shadow: 0 4px 6px rgba(52, 152, 219, 0.3);
      
      &:hover {
        background-color: #2980b9;
        transform: translateY(-2px);
      }
    }
    
    .report-button {
      background-color: rgba(255, 255, 255, 0.1);
      color: #E0E0E0;
      backdrop-filter: blur(5px);
      
      &:hover {
        background-color: rgba(255, 255, 255, 0.2);
        transform: translateY(-2px);
      }
    }
  }
}

@keyframes trainMove {
  0% {
    transform: translateX(-300px) scaleX(-1);
  }
  40% {
    transform: translateX(calc(100% - 280px)) scaleX(-1);
  }
  40.1% {
    opacity: 1;
  }
  40.2% {
    opacity: 0;
    transform: translateX(calc(100% - 280px)) scaleX(-1);
  }
  40.3% {
    opacity: 0;
    transform: translateX(-300px) scaleX(-1);
  }
  40.4% {
    opacity: 1;
  }
  100% {
    transform: translateX(calc(100% - 280px)) scaleX(-1);
  }
}

@keyframes wheelRotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

@keyframes smokeRise {
  0% {
    transform: translateY(0) scale(1);
    opacity: 0.8;
  }
  100% {
    transform: translateY(-40px) scale(2);
    opacity: 0;
  }
}

@keyframes blinkBroken {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.6;
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 768px) {
  .error-content {
    width: 95%;
  }
  
  .train-scene {
    height: 180px;
  }
  
  .error-message {
    .error-code {
      font-size: 80px;
    }
    
    .error-title {
      font-size: 26px;
    }
    
    .error-desc {
      font-size: 16px;
    }
    
    .actions {
      flex-direction: row;
      justify-content: center;
      
      .home-button {
        width: auto;
        min-width: 140px;
      }
    }
  }
  
  .train {
    transform: scale(0.8);
    transform-origin: left bottom;
  }
}
</style>
